home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 42 / Amiga Format AFCD42 (Issue 126, Aug 1999).iso / -serious- / programming / arexx / rxcmanager / examples / e2yam.rexx < prev    next >
OS/2 REXX Batch file  |  1999-05-25  |  1KB  |  82 lines

  1. /*
  2. Author:        Alfonso Ranieri <alfier@iol.it>
  3. Desription:    export to Yam Addresses list
  4. Template:      KEY,USER/K
  5. Tipical usage: rx e2yam >file
  6. */
  7.  
  8. call addlib("rmh.library",0,-30) then exit
  9. call addlib("rxcmanager.library",0,-30) then exit
  10.  
  11. if ~open("STDERR","CONSOLE:","W") then stderr="STDOUT"
  12.  
  13. prg=programname("NOEXT")
  14. if ~RMH_ReadArgs("KEY,USER/K") then do
  15.     call PrintFault(IoErr(),prg)
  16.     exit
  17. end
  18.  
  19. if parm.0.flag then k = "#?"parm.0.value"#?"
  20. else k = "#?"
  21.  
  22. if parm.1.flag then
  23.     call CMUserData(parm.1.value)
  24.  
  25. patt.Name    = k
  26. patt.Surname = k
  27. patt.Email     = k
  28. patt.Alias   = k
  29.  
  30. num = CMFind("USER GROUPS","USER","PATT")
  31.  
  32. if num=1 then call info "No user entry found"
  33. else call info "Found" num "user(s)"
  34.  
  35. say 'YAB3 - YAM Addressbook'
  36.  
  37. g=""
  38. p=""
  39. ng=0
  40. do i=0 to num-1
  41.     if user.i.Group~=g then do
  42.         if g~="" then do
  43.             if user.i.Group~=g & user.i.parents="" then do
  44.             call endG
  45.             end
  46.         end
  47.         say "@GROUP" user.i.Group
  48.         say
  49.         ng=ng+1
  50.         g=user.i.Group
  51.     end
  52.     if ~user.i.EmptyGroup then do
  53.         say '@USER' user.i.Alias
  54.         say user.i.Email
  55.         say user.i.Name user.i.LastName
  56.         say
  57.         say user.i.Phone
  58.         say user.i.Address
  59.         say user.i.ZIP
  60.         say user.i.Country
  61.         say
  62.         say
  63.         say
  64.         say user.i.WWW
  65.         say '@ENDUSER'
  66.     end
  67. end
  68. call endG
  69. exit
  70.  
  71. info: procedure expose stderr prg
  72. parse arg msg
  73.     call WriteLN(stderr,prg":" msg)
  74.     return
  75.  
  76. endG: procedure expose ng
  77.     do j=0 to ng-1
  78.         say "@ENDGROUP"
  79.     end
  80.     ng=0
  81.     return
  82.